<!--Descriptive page name, messages and instructions-->
<h2><%=h t('.my_inbox', :default => 'My Inbox') %> (<%= t('.inbox_count', :default => "%{total} comments, %{unread} unread", :total => @inbox_total, :unread => @unread) %>)</h2>

<%= flash_div :comment_error, :comment_notice %>
<!--/descriptions-->

<!--main content-->
<% unless @inbox_comments.blank? %>  
  <%= form_tag user_inbox_path(@user), :method => :put, :id => 'inbox-form' do %>
  <fieldset>
	<legend>Mass Edit Options</legend>
	<ul class="navigation">
    <li>Select: </li>
    <li>
      <a onclick="$('inbox-form').getInputs('checkbox', 'inbox_comments[]').each(function(box){box.checked = 1})">all</a>
    </li>
    <li>
      <a onclick="$('inbox-form').getInputs('checkbox', 'inbox_comments[]').each(function(box){box.checked = 0})">none</a>
    </li>
  </ul>
	<p class="submit">
      <%= "Mark checked as:" %> 
      <%= submit_tag t('.read', :default => 'Read'), :name => 'read' %>
      <%= submit_tag t('.unread', :default => 'Unread'), :name => 'unread' %>
      <%= submit_tag t('.delete_from_inbox', :default => 'Delete From Inbox'), :name => 'delete' %>
  </p>
	</fieldset>
	<fieldset>
	<legend>List of Comments</legend>
	<ol class="comment index">
    <% for inbox_comment in @inbox_comments %>
      <!-- START of single comment -->
      <li class="comment <%= inbox_comment.read? ? 'read' : 'unread' %> <%= cycle :odd, :even %>" role="article">
        <h4><%= get_commenter_pseud_or_name(inbox_comment.feedback_comment) %> <%= 'to' %> <%= commentable_description_link(inbox_comment.feedback_comment) %> </h4>
        <div class="icon">
          <% if !inbox_comment.feedback_comment.pseud.nil? %>
            <%= standard_icon_display(inbox_comment.feedback_comment.pseud.user, inbox_comment.feedback_comment.pseud) %>
          <% else %>
            <span class="visitor icon"><!-- visitor icon holder --></span>
          <% end %>
        </div>
        <blockquote class="userstuff"><%=raw sanitize_field(inbox_comment.feedback_comment, :content) %></blockquote>
        <p class="datetime"><%= distance_of_time_in_words_to_now(inbox_comment.created_at) %></p>
        <h5 class="landmark">Comment Actions</h5>
        <ul class="navigation">
          <% unless inbox_comment.read? %>
            <li><span class="unread">Unread</span></li>
          <% end %>
          <li>
            <%= image_tag("replied_to.png", :size => "15x15", :alt => "Replied To") if inbox_comment.replied_to? %>
            <%= link_to "Reply", reply_user_inbox_path(current_user, :comment_id => 
inbox_comment.feedback_comment), :remote => true %>
          </li>
          <li>
            <%= label_tag "inbox_comments_#{inbox_comment.id}", "Select" %>
            <%= check_box_tag "inbox_comments[]", inbox_comment.id, false, :title => "select this comment", :id => "inbox_comments_#{inbox_comment.id}" %>
          </li>
        </ul>
      </li>
      <!-- END of single comment -->
    <% end %>
  </ol>
  </fieldset>
  <fieldset>
	<legend>Mass Edit Options Again</legend>
	<ul class="navigation">
    <li>Select: </li>
    <li>
      <a onclick="$('inbox-form').getInputs('checkbox', 'inbox_comments[]').each(function(box){box.checked = 1})">all</a>
    </li>
    <li>
      <a onclick="$('inbox-form').getInputs('checkbox', 'inbox_comments[]').each(function(box){box.checked = 0})">none</a>
    </li>
  </ul>
    <p class="submit">
      <%= hidden_field_tag("filters[read]", params[:filters][:read]) if params[:filters] %>
      <%= hidden_field_tag("filters[replied_to]", params[:filters][:replied_to]) if params[:filters] %>
      <%= hidden_field_tag("filters[date]", params[:filters][:date]) if params[:filters] %>
      <%= "Mark checked as:" %> 
      <%= submit_tag t('.read', :default => 'Read'), :name => 'read' %>
      <%= submit_tag t('.unread', :default => 'Unread'), :name => 'unread' %>
      <%= submit_tag t('.delete_from_inbox', :default => 'Delete From Inbox'), :name => 'delete' %>
    </p>
  </fieldset>
    <!-- coming soon <%= submit_tag t('.mass_reply', :default => 'mass reply') %> -->
  <% end %> <!-- end of inbox form -->
  
  <!-- we can't open comment forms inside the inbox form, which is why this is down here -->
  <div id="reply-to-comment" style="display:none;"></div> <!-- this div will contain the reply to comment form -->
<% end %>

<!--/content-->

<!--subnav-->
<h3 class="landmark">Filter</h3>
<%= form_tag(user_inbox_path(@user), :class => 'filters', :method => :get) do %>
  <%= field_set_tag do %>
    <dl class="filters">
      <dt><%= 'Filter by read' %></dt>
      <dd>
        <%= radio_button_tag 'filters[read]', 'all', (@select_read != 'true' && @select_read != 'false') %>
        <%= label_tag 'filters_read_all', 'Show all' %>
      </dd>
      <dd>
        <%= radio_button_tag 'filters[read]', 'false', @select_read == 'false' %>
        <%= label_tag 'filters_read_false', 'Show unread' %>
      </dd>
      <dd>
        <%= radio_button_tag 'filters[read]', 'true', @select_read == 'true' %>
        <%= label_tag 'filters_read_true', 'Show read' %>
      </dd>

      <dt><%= 'Filter by replied to' %></dt>
      <dd>
        <%= radio_button_tag 'filters[replied_to]', 'all', (@select_replied_to != 'true' && @select_replied_to != 'false') %>
        <%= label_tag 'filters_replied_to_all', 'Show all' %>
      </dd>
      <dd>
        <%= radio_button_tag 'filters[replied_to]', 'false', @select_replied_to == 'false' %>
        <%= label_tag 'filters_replied_to_false', 'Show without replies' %>
      </dd>
      <dd>
        <%= radio_button_tag 'filters[replied_to]', 'true', @select_replied_to == 'true' %>
        <%= label_tag 'filters_replied_to_true', 'Show replied to' %>
      </dd>

      <dt><%= 'Sort by date' %></dt>
      <dd>
        <%= radio_button_tag 'filters[date]', 'DESC', @select_date != 'ASC' %>
        <%= label_tag 'filters_date_desc', 'Newest first' %>
      </dd>
      <dd>
        <%= radio_button_tag 'filters[date]', 'ASC', @select_date == 'ASC' %>
        <%= label_tag 'filters_date_asc', 'Oldest first' %>
      </dd>
    </dl>
  <% end %>
  <p class="submit"><%= submit_tag t('.filter_inbox', :default => 'Filter Inbox') %></p>
<% end %>
<!--/subnav-->

